package com.star.files.service;

import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 文件管理服务
 *
 * @author yangzj
 */
public interface FilesService {

    /**
     * 单文件上传
     *
     * @param file         文件
     * @param fileCategory 文件分类
     * @param keepFileName 保持文件名
     * @return {@link String}
     */
    String upload(MultipartFile file, String fileCategory, Boolean keepFileName);

    /**
     * 多文件上传
     *
     * @param files        文件
     * @param fileCategory 文件分类
     * @param keepFileName 保持文件名
     * @return {@link List}<{@link String}>
     */
    List<String> uploads(MultipartFile[] files, String fileCategory, Boolean keepFileName);

    /**
     * url单文件上传
     *
     * @param url          url
     * @param fileCategory 文件类别
     * @param keepFileName 保持文件名
     * @return {@link String}
     */
    String upload(String url, String fileCategory, Boolean keepFileName);

    /**
     * url多文件上传
     *
     * @param fileCategory 文件分类
     * @param keepFileName 保持文件名
     * @param urls         url
     * @return {@link List}<{@link String}>
     */
    List<String> uploads(List<String> urls, String fileCategory, Boolean keepFileName);

    /**
     * 删除
     *
     * @param filePath         filePath
     * @param isThrowException 是否抛出异常
     */
    void delete(String filePath, boolean isThrowException);

    /**
     * 下载
     *
     * @param filePath 文件路径
     * @param response 响应
     * @param request HttpServletRequest
     */
    void download(String filePath, HttpServletRequest request, HttpServletResponse response);
}
